<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="themaopdracht.Gegevens"%>
<%@ page import="themaopdracht.PMF" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%!private Gegevens g = new Gegevens();%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cijfer Formulier</title>
</head>
<body>
	<%
		Gegevens g = new Gegevens();
		g.setNaam(request.getParameter("naam"));
		g.setEmailadres(request.getParameter("emailadres"));
		g.setAfmeldenvan(request.getParameter("van"));
		g.setAfmeldentot(request.getParameter("tot"));
		g.setStudentnr(request.getParameter("studentnr"));

		if (!(g.getStudentnr().isEmpty()) && !(g.getNaam().isEmpty())
				&& !(g.getAfmeldenvan().isEmpty()) && !(g.getAfmeldentot().isEmpty())
				&& !(g.getEmailadres().isEmpty())) {
			PersistenceManager pmWrite = PMF.get().getPersistenceManager();
			try {
				pmWrite.makePersistent(g);
			} finally {
				pmWrite.close();
			}
		}
	%>

	<br />
	<%
		PersistenceManager pmRead = PMF.get().getPersistenceManager();
		String query = "select from " + Gegevens.class.getName();
		List<Gegevens> gegevens = (List<Gegevens>) pmRead.newQuery(query).execute();
	%>
	<%
		if (!gegevens.isEmpty()) {
			for (Gegevens gegeven : gegevens) {
	%>
	van:
	<b><%=gegeven.getNaam()%></b>:
	<br />
	<i><%=gegeven.getEmailadres()%></i>
	<br />
	<i><%=gegeven.getStudentnr()%></i>
	<br />
	<i><%=gegeven.getAfmeldenvan()%></i>
	<br />
	<i><%=gegeven.getAfmeldentot()%></i>
	<br />
	<hr>
	<%
			}
		}
		pmRead.close();
	%>
	</body>